#ifndef _BASE_BASE_
#define _BASE_BASE_

#include "../stdafx.h"

#define M_PI				3.14159265358979323846264335
#define EPS					1e-4

#define DEG_TO_RAD(m_x)		((m_x) * M_PI / 180)
#define RAD_TO_DEG(m_x)		((m_x) * 180 / M_PI)
#define IS_LEAP_YEAR(year)	(year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))

struct CDate
{
	int m_timeZone;
	int m_year;
	int m_month;
	int m_day;
	int m_hour;
	int m_minute;

	void SetDate(int timeZone, int year, int month, int day, int hour, int minute);
};

struct CGeoInfo
{
	float m_longitude;
	float m_latitude;
};

struct CSpherePosition
{
	float m_elevation;
	float m_azimuth;
};

struct CClearSkyParameter
{
	float m_a;
	float m_b;
	float m_c;
	float m_d;
	float m_e;

	float m_Lp;

	void SetParameters(float a, float b, float c, float d, float e, float Lp);
	void SetParameters(float para[]);
};

struct CPixel
{
	int m_x;
	int m_y;
};

struct CColor
{
	float m_r;
	float m_g;
	float m_b;

	float& operator[](int i)
	{
		switch (i)
		{
		case 0:
			return m_r;
		case 1:
			return m_g;
		case 2:
			return m_b;
		default:
			return m_r;
		}
	}
};

struct CPoint3D
{
	float m_x;
	float m_y;
	float m_z;

	void SetPoint(float x, float y, float z);
	void Normalize();
};

int Date2Num(int year, int month, int day);
int Date2Num(CDate date);
void Str2Char(CString str, char* pChar);

bool CalcCoords(CPoint3D pInA, CPoint3D pInB, CPoint3D xInB, CPoint3D &yInB, CPoint3D &zInB);
CPoint3D Cross(CPoint3D u, CPoint3D v);


#endif